/*************************************************************************
 *                  HONGLING CAPITAL CONFIDENTIAL AND PROPRIETARY
 *
 *                COPYRIGHT (C) HONGLING CAPITAL CORPORATION 2012
 *    ALL RIGHTS RESERVED BY HONGLING CAPITAL CORPORATION. THIS PROGRAM
 * MUST BE USED  SOLELY FOR THE PURPOSE FOR WHICH IT WAS FURNISHED BY
 * HONGLING CAPITAL CORPORATION. NO PART OF THIS PROGRAM MAY BE REPRODUCED
 * OR DISCLOSED TO OTHERS,IN ANY FORM, WITHOUT THE PRIOR WRITTEN
 * PERMISSION OF HONGLING CAPITAL CORPORATION. USE OF COPYRIGHT NOTICE
 DOES NOT EVIDENCE PUBLICATION OF THE PROGRAM.
 *                  HONGLING CAPITAL CONFIDENTIAL AND PROPRIETARY
 *************************************************************************/

package com.hongling.controller;

import com.hongling.uc.domain.UserDTO;
import com.hongling.uc.service.DemoService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * 测试核心控制类。
 *
 * @author hongchao zhao at 2019-7-30 15:07
 */
@Controller
public class IndexController {

    private static Logger LOG = LoggerFactory.getLogger(IndexController.class);

    @Resource
    private DemoService demoService;

    @RequestMapping("/index")
    public String index(HttpServletRequest request, Model model,@RequestParam Integer id) {
        LOG.debug("进入JSP请求模板。。。");
        UserDTO user = demoService.getUserById(id);
        model.addAttribute("msg", "欢迎【" + user.getUserName() + "】来到Spring Boot的领域！");
        return "jsp/index";
    }

    @RequestMapping("/index2")
    public String index2(HttpServletRequest request, Model model,@RequestParam Integer id) {
        LOG.debug("进入HTML请求模板。。。");
        UserDTO user = demoService.getUserById(id);
        model.addAttribute("msg", "欢迎【" + user.getUserName() + "】来到Spring Boot的领域！");
        return "html/index";
    }

}
